#ifndef LCD_COMM_H
#define LCD_COMM_H
#include "sc95f.h"
#include "string.h"
#define SDA_624         P16
#define SCL_624         P17    

#define Rinnai_VERSION_NUMBER            1
#define Rinnai_VERSION_LETTER            0

#define LED_H          1
#define LED_L          0

#define SEG01             (0X00)
#define SEG02             (0X08)
#define SEG03             (0X10)
#define SEG04             (0X18)
#define SEG05             (0X20)
#define SEG06             (0X28)
#define SEG07             (0X30)
#define SEG08             (0X38)
#define SEG09             (0X40)
#define SEG010            (0X48)

#define GRID01            (0X00)
#define GRID02            (0X01)
#define GRID03            (0X02)
#define GRID04            (0X03)
#define GRID05            (0X04)
#define GRID06            (0X05)
#define GRID07            (0X06)
#define GRID08            (0X07)

#define LED_MAX             (0XFF)
#define LED_MIN             (0X00)
#define LED_OPEN            (0x64)
#define LED_CLOSE           (0X00)

#define LCD_0               (0x3f)
#define LCD_1               (0x06)
#define LCD_2               (0x5b)
#define LCD_3               (0x4f)
#define LCD_4               (0x66)
#define LCD_5               (0x6d)
#define LCD_6               (0x7d)
#define LCD_7               (0x07)
#define LCD_8               (0x7f)
#define LCD_9               (0x6f)
#define LCD_A               (0x77)
#define LCD_B               (0x7c)
#define LCD_C               (0x39)
#define LCD_D               (0x5e)
#define LCD_E               (0x79)
#define LCD_F               (0x71)
#define LCD_N               (0X54)
#define LCD_V               (0x40)
#define LCD_X               (0x00)//不显�?
#define LCD_L               (0x38)
#define LCD_H               (0x76)
#define LCD_O               (0x5c)
#define LCD_K               (0x49)//数码管三�?
#define LCD_W               (0x36)//数码管两�?
#define LCD_P               (0x73)
#define LCD_S               (0x6d)
#define LCD_T               (0x40)

#define LED_01              (SEG08|GRID05)
#define LED_02              (SEG05|GRID05)
#define LED_03              (SEG04|GRID05)
#define LED_04              (SEG08|GRID04)
#define LED_05              (SEG05|GRID04)
#define LED_06              (SEG04|GRID04)
#define LED_07              (SEG08|GRID03)
#define LED_08              (SEG05|GRID03)

#define LED_09              (SEG04|GRID03)
#define LED_10              (SEG07|GRID03)
#define LED_11              (SEG01|GRID03)
#define LED_12              (SEG03|GRID03)
#define LED_13              (SEG02|GRID03)
#define LED_14              (SEG08|GRID02)
#define LED_15              (SEG05|GRID02)

#define LED_16              (SEG04|GRID02)
#define LED_17              (SEG07|GRID02)
#define LED_18              (SEG01|GRID02)
#define LED_19              (SEG03|GRID02)
#define LED_20              (SEG02|GRID02)
#define LED_21              (SEG06|GRID02)
#define LED_22              (SEG08|GRID01)
#define LED_23              (SEG05|GRID01)

#define LED_24              (SEG04|GRID01)
#define LED_25              (SEG07|GRID01)
#define LED_26              (SEG01|GRID01)
#define LED_27              (SEG03|GRID01)
#define LED_28              (SEG02|GRID01)
#define LED_29              (SEG08|GRID06)
#define LED_30              (SEG05|GRID06)
#define LED_31              (SEG04|GRID06)

#define LED_32              (SEG08|GRID07)
#define LED_33              (SEG05|GRID07)
#define LED_34              (SEG04|GRID07)
#define LED_35              (SEG010|GRID08)
#define LED_36              (SEG09|GRID08)
#define LED_37              (SEG06|GRID08)
#define LED_38              (SEG05|GRID02)
#define LED_39              (SEG05|GRID01)

#define LED_40              (SEG06|GRID08)
#define LED_41              (SEG06|GRID07)
#define LED_42              (SEG06|GRID06)
#define LED_43              (SEG06|GRID05)
#define LED_44              (SEG06|GRID04)
#define LED_45              (SEG06|GRID03)

#define LED_46              (SEG08|GRID08)
#define LED_47              (SEG08|GRID07)
#define LED_48              (SEG08|GRID06)

#define LED_49              (SEG09|GRID08)
#define LED_50              (SEG09|GRID07)
#define LED_51              (SEG09|GRID06)

#define LED_52              (SEG010|GRID08)
#define LED_53              (SEG010|GRID07)
#define LED_54              (SEG010|GRID06)

#define WIFI_LED            (LED_32)
#define ECO_LED             (LED_34)
#define TEMP_C              (LED_31)
#define POINT               (LED_21)
#define RESERVE1            (LED_29)
#define RESERVE2            (LED_30)
#define RESERVE3            (LED_33)
#define FIRE1               (LED_35)
#define FIRE2               (LED_36)
#define FIRE3               (LED_37)
#define BATHTUB             (LED_01)
#define CYCLE               (LED_02)
#define BOOSTER             (LED_03)
#define KITCHEN             (LED_04)
#define BATH                (LED_05)
#define HOT_AND_COOL        (LED_06)


#define LED_TIME             (0X0A)
#define LED_BREATH_MAX_DATA  (50)
#define LED_BREATH_MAX_DATA_1  (49)

typedef struct 
{
    uint8_t wifiled:1;
    uint8_t ecoled :1;
    uint8_t temp_c_led:1;
    uint8_t pointled :1;
    uint8_t barhtubled:1;
    uint8_t reserve1:1;
    uint8_t reserve2:1;
    uint8_t reserve3:1;
    
    
    uint8_t cycleled:1;
    uint8_t booster:1;
    uint8_t kitchen:1;
    uint8_t bathled:1;
    uint8_t hotandcool:1;
    uint8_t fire1:1;
    uint8_t fire2:1;
    uint8_t fire3:1;

}LED_STRUCT;

typedef union 
{
   LED_STRUCT led_struct;
   uint8_t led_arry[2];
}LED_UNION;
extern LED_UNION led_union;
void dispaly_init(void);
void lcd_process_stat(void);
void AiP33624_write(unsigned char dat);
void display_send(void);
void wifi_display(void);
//void AiP33624_stop(void);
//void AiP33624_start(void);
void display_breathing_fuction(void);
void err_display_clean(uint8_t clean_eco_code,uint8_t clean_fire_code,uint8_t cricle,uint8_t pressure,uint8_t mode,uint8_t coolhot);
void display_run(uint16_t temp, uint8_t eco_code,uint8_t fire_code,uint8_t cricle,uint8_t pressure,uint8_t mode,uint8_t yugan,uint8_t coolhot);
void display_version(uint8_t temp1, uint8_t temp2,uint8_t eco_code,uint8_t fire_code,uint8_t cricle,uint8_t pressure);
void display_err_fire(uint8_t err_code,uint8_t err_code_l);
void display_err_action(uint8_t ac_code,uint8_t ac_code_l, uint8_t eco_code,uint8_t fire_code,uint8_t cricle,uint8_t pressure,uint8_t mode,uint8_t yugan,uint8_t coolhot);
void display_all(void);
void display_clean(void);
void fire_breath_diaplay(uint8_t fire);
#ifdef OPEN_POWER_FLAG
void display_openpowercode(uint8_t code0,uint8_t code1,uint8_t code2);
void display_reset_openpowercode_index(void);
void display_openpowercode1(uint8_t code0);
void display_openpowercode2(void);
void display_Temperature_Clean(void);
#endif
void display_led(uint8_t *buf);
#endif
